/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Pronostico.java
 *
 * Created on 09-oct-2011, 21:34:56
 */
package Principal.regresion;

import java.util.ArrayList;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import librerias.regresion.EscalaMovil;
import librerias.regresion.ListaDobleConOrden;
import librerias.regresion.NodoDoble;

/**
 *
 * @author JONATHAN
 */
public class Pronostico extends javax.swing.JFrame {
    public DefaultTableModel miModelo;
    public String[][] data = {};

    Pronostico(ArrayList arreglo_pronostico) {
        initComponents();
        setLocationRelativeTo(null);
        miModelo = new DefaultTableModel(data, new String[]{"Periodo", "Pronostico Y",}) {
        };
        Tabla_1.setModel(miModelo);
        jScrollPane1.setViewportView(Tabla_1);
        Llenar_Tabla(arreglo_pronostico);
    }

    JTable getMiTabla() {
        return Tabla_1;
    }

    public DefaultTableModel getMiModelo() {
        return miModelo;
    }
    /** Creates new form Pronostico */

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        Tabla_1 = new javax.swing.JTable();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Pronostico");

        Tabla_1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane1.setViewportView(Tabla_1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 396, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(24, 24, 24)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 309, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(24, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTable Tabla_1;
    private javax.swing.JScrollPane jScrollPane1;
    // End of variables declaration//GEN-END:variables
    private void inicializaTabla() {
        // obtiene numero de filas de la tabla
        int filas = getMiTabla().getRowCount();
        // remueve todas las filas de la tabla
        for (int fila = 0; fila < filas; fila++) {
            getMiModelo().removeRow(0);
        }
    }

    private void Llenar_Tabla(ArrayList arreglo_pronostico) {
        inicializaTabla();
        for(int k=0;k<arreglo_pronostico.size();k++){
            Object[] datos = {(k+1),arreglo_pronostico.get(k)};
            getMiModelo().addRow(datos);
        }
    }
}
